package cmd

import (
	"starsine.cn/appTpl/cmn/cmd"
	. "starsine.cn/appTpl/cmn/defs"
	"starsine.cn/appTpl/cmn/logs"
)

var console *cmd.Console = nil

func Start(appCtxt *AppContext) {

	app := GCliStart()

	var err error = nil
	console, err = cmd.New(cmd.Config{}, app)
	if err != nil {
		logs.Warnf("create console fail, error: ", err)
	} else {
		logs.Infof("create console success.")
	}
	console.Welcome()
	go console.Interactive()

	logs.Infof("cmd Start.")
}

func CmdExec(command string) string {
	return console.Evaluate(command)
}
